#include<iostream>
#include<vector>
#include<map>
#include<deque>
#include<algorithm>
using namespace std;

const int SIZE = 100;
const int ID_SIZE = 3;

// use map to repr tree
// and do BFS, memo height info

inline int sid2int()
{
    int res;
    char sid[ID_SIZE]; scanf("%s",sid);
    sscanf(sid[0]=='0'?sid+1:sid, "%d",&res);
    return res;
}

int main(int argc, char const *argv[])
{
    freopen("test.txt","r",stdin);
    int N,M; cin>>N>>M;
    map<int,vector<int>> tree;
    for(int i = 0;i<M;++i)
    {
        int id = sid2int(); 
        int K;cin>>K;
        vector<int> child;
        for(int j = 0;j<K;++j)
            child.push_back(sid2int()); 
        tree[id] = child;
    }

    // BFS 
    struct ID_H { int id; int h; };
    deque<ID_H> q;
    ID_H root {1,0};    // height start from 0
    q.push_back(root);
    int res[SIZE]{0};   // store the res
    int cur_h = -1;
    while (!q.empty())
    {
        ID_H tmp = q.front(); q.pop_front();
        cur_h = cur_h>tmp.h ? cur_h : tmp.h;
        if(tree[tmp.id].empty())
            res[tmp.h]++;
        for(auto x:tree[tmp.id])
        {
            ID_H child{x,tmp.h+1};
            q.push_back(child);
        }
    }
    cout<<res[0];
    for(int i = 1;i<=cur_h;++i)
        cout<<" "<<res[i];

    return 0;
}
